<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>金字塔</title>
</head>
<body>

<script>
    var colors = ["#FF0000", "#00ffg0", "#dFf0h0", "#Fh5f00", "#F5bd00", "#nfuf00", "#00tff", "#0Ffft0",];

        for (var i = 2; i <= 500; i += 10) {
            var res = Math.random() * colors.length;
            var number = Math.floor(res);
            document.write("<hr size='2' width='" + i + "' color='" + colors[number] + "'>");//加号拼接
        }
       // location.reload()
</script>

</body>
</html>